import onnx

fp16_op_list = ['Conv', 'Relu', 'LeaklyRelu', 'Add', 'SigMoid', 'AveragePool', 'MaxPool', 'SoftMax']

def analyze(onnxfile, **kwargs):
    model = onnx.load(onnxfile)

    chk_list = []

    for node in model.graph.node:
        if node.op_type in fp16_op_list:
            #print('op_type:', node.op_type, node.input, node.output, ', name:', node.name)
            for n in node.input:
                chk_list.append(n)

            for n in node.output:
                chk_list.append(n)    

    for v in model.graph.value_info:
        if v.name in chk_list:
            #print('v.name', v.name)
            if v.type.tensor_type.elem_type != 10:
                #print('v.type.tensor_type.elem_type = ', v.type.tensor_type.elem_type)
                return False  

    for init in model.graph.initializer:
        if init.name in chk_list:
            #print('init.name', init.name)
            if init.data_type != 10:
                return False

    return True